package rabbitmq

import (
	"app/util"
	"errors"
	"github.com/streadway/amqp"
)

func (rq *Channel) Publish(msg []byte) (err error) {

	err = rq.channel.Publish(rq.pusherconf.Exchange,
		rq.pusherconf.Key,
		rq.pusherconf.Mandtory,
		rq.pusherconf.Immediate,
		amqp.Publishing{ContentType: rq.pusherconf.ContentType, Body: msg})
	if err != nil {
		util.Error("rabbitmq push message error")
		return errors.New("rabbitmq push message error")
	}

	return nil
}
